package com.linuxgt.pattern.adapter.scheme2;

public class Application {
    public static void main(String[] args) {
        ThreeElectrcOutlet threeOutlet;//ThreeElectrcOutlet接口（三相插座）
        TwoElectrcOutlet twoOutlet;//TwoElectrcOutlet（两相插座）
        Wash wash = new Wash();//洗衣机
        TV tv = new TV();//电视机
        ThreeAndTwoElectrcAdapter adapter = new ThreeAndTwoElectrcAdapter(wash, tv);//双向适配器
        threeOutlet = adapter;//适配器插在三相插座上
        System.out.println("使用三相插座接通电流：");
        threeOutlet.connectElectricCurrent();
        twoOutlet = adapter;//适配器插在两相插座上
        System.out.println("使用两相插座接通电流");
        twoOutlet.connectElectricCurrent();
    }
}


class Wash implements ThreeElectrcOutlet {//洗衣机使用三相插座
    String name;

    Wash() {
        name = "黄河洗衣机";
    }

    Wash(String s) {
        name = s;
    }

    @Override
    public void connectElectricCurrent() {
        turnOn();
    }

    public void turnOn() {
        System.out.println(name + "开始泳衣物");
    }
}

class TV implements TwoElectrcOutlet {//电视机使用两相插座
    String name;

    TV() {
        name = "长江电视机";
    }

    TV(String s) {
        name = s;
    }

    @Override
    public void connectElectricCurrent() {
        turnOn();
    }

    public void turnOn() {
        System.out.println(name + "开始播放节目。");
    }
}